{
    title:  'Pipeline Stages',
    crumbs: [
        { "User's Guide": '../users/' },
    ],
}
            <h1>Configuring Pipeline Stages</h1>
            <p>Appweb uses a bidirectional pipeline to process requests and generate responses. This consists of a
            mechanism of queues, packets, buffering and event scheduling. The pipeline architecture is highly optimized
            and supports the efficient transmission of data without copying.</p>
            <p>The request pipeline is comprised of an incoming and outgoing stream. Each stream is in turn comprised
            of stages.</p>
            <img src="../images/pipeline.jpg" alt="pipeline" class="centered"/>
            <p>Stages come in three varieties:</p>
            <ul>
                <li>Handlers</li>
                <li>Filters</li>
                <li>Network Connectors</li>
            </ul>
            <p>Handlers are responsible for generating the response content. Filters permute the request or incoming
            and outgoing data in some way, and network connectors send the final response over the network to the
            client.</p>
            <p>Appweb has a set of handlers for common application and content types. Different handlers service
            different content. Appweb provides the following handlers: PHP, CGI, ESP, Ejscript, directory listings,
            and a file handler for static file content. An API is also provided so you can create your own
            request handlers and pipeline filters and connectors.</p>
            <h2>Handlers</h2>
            <p>Appweb handlers typically utilize the Appweb <a href="modules.html">loadable module</a> interface and
            may be dynamically loaded and configured via the <a href="configuration.html">Appweb configuration
            file</a>. The configuration file defines the handlers to use and the order in which they are matched to a
            given request.</p><a id="handlerProcessing"></a>
            <h3>Handler Processing</h3>
            <p>The following is an example set of Appweb configuration file directives that loads modules and defines
            the handlers to process client requests.</p>
            <pre class="ui code segment">
<a href="dir/module.html#loadModule">LoadModule</a> ejs mod_ejs
LoadModule file mod_file
<a href="dir/route.html#addHandler">AddHandler</a> ejsHandler ejs
<a href="dir/route.html#addHandler">AddHandler</a> fileHandler
</pre>
            <p>The order of the directives is important. When a request is received from a client, the handlers
            specified in the configuration file will be matched against the request. If a handler does not specify an
            extension, then it will always match. If the request URL
            extension matches the extension for a handler, then that handler will be added to the list of handlers for
            this request.</p>
            <p>For example: "http://www.acme.com/myDoc.esp" would match the ".esp" extension for the ejsHandler. The
            result is a list of handlers that will be applied to the request in the order they appear in the
            configuration file. The first matching handler to accept the request will be responsible for the
            request.</p>
            <h2>Filters</h2>
            <p>Filters can manipulate the request as it passes through the request pipeline. Typical uses are to
            compress or encrypt data. Appweb implements Transfer Chunk Encoding and Ranged requests via filters. 
            Filters are configured via the <a href="dir/route.html#addInputFilter">AddInputFilter</a>
            and <a href="dir/route.html#addOutputFilter">AddOutputFilter</a> configuration file directives.</p>
            <h2>Connectors</h2>
            <p>Network connectors are the end of the outgoing stream of the pipeline. Their job is to transmit data
            back to the client. Appweb supplies two connectors. One general purpose <b>net</b> connector and a
            specialize <b>send</b> connector for static file content.</p>
            <p>Please see the document <a href="../developers/stages.html">Extending via Pipeline Stages</a> for
            programming information about how to create Appweb handlers, filters and connectors.</p>
